package com.wf.course.service.impl;

import com.utils.page.PageBean;
import com.wf.course.dao.ICourseWorkMapper;
import com.wf.course.model.course.CourseWork;
import com.wf.course.service.ICourseWorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class ICourseWorkServiceImpl implements ICourseWorkService {

    @Autowired
    private ICourseWorkMapper courseWorkMapper;

    @Override
    public void list(PageBean<CourseWork> pageBean) {
        pageBean.setResults(courseWorkMapper.list(pageBean));
        pageBean.setTotalCount(courseWorkMapper.count(pageBean));
    }

    @Override
    public CourseWork searchCourseWork(Integer id) {
        return courseWorkMapper.searchCourseWork(id);
    }

    @Override
    public Integer insert(CourseWork courseWork) {
        return courseWorkMapper.insert(courseWork);
    }

    @Override
    public Integer update(CourseWork courseWork) {
        return courseWorkMapper.update(courseWork);
    }

    @Override
    public Integer delete(Integer id) {
        return courseWorkMapper.delete(id);
    }

    @Override
    public Integer updateForm(CourseWork courseWork) {
        return update(courseWork);
    }

    @Override
    public void memberWorkList(PageBean<CourseWork> pageBean) {
        pageBean.setResults(courseWorkMapper.memberWorkList(pageBean));
        pageBean.setTotalCount(courseWorkMapper.memberWorkCount(pageBean));
    }

    @Override
    public CourseWork searchMemberWork(Integer id) {
        return courseWorkMapper.searchMemberWork(id);
    }

    @Override
    public Integer updateMemberWork(CourseWork courseWork) {
        return courseWorkMapper.updateMemberWork(courseWork);
    }

    @Override
    public Integer deleteMemberWorkByChapterId(Integer chapterId) {
        return courseWorkMapper.deleteMemberWorkByChapterId(chapterId);
    }
}
